Skip to content

fix(cloudflare): Instrument custom WorkerEntrypoint RPC methods#22310

Merged
JPeer264 merged 4 commits into
getsentry:developfrom
akshitsinha:fix/cloudflare-worker-entrypoint-rpc
Jul 17, 2026
Merged

fix(cloudflare): Instrument custom WorkerEntrypoint RPC methods#22310
JPeer264 merged 4 commits into
getsentry:developfrom
akshitsinha:fix/cloudflare-worker-entrypoint-rpc

Conversation

@akshitsinha

@akshitsinha akshitsinha commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

withSentry() only wraps the lifecycle handlers on WorkerEntrypoint (fetch, scheduled, queue, tail). Custom RPC methods never get wrapped, so errors thrown in them are not captured and trace propagation does not work for them.

This mirrors what we already do for Durable Objects in durableobject.ts: the constructor proxy returns an instance proxy that catches RPC methods as workerd accesses them, and wraps them using the same wrapMethodWithSentry helper.

The generic typing change on instrumentWorkerEntrypoint / WorkerEntrypointConstructor also fixes #22233, where the Env generic was ignored and the constructor parameter was always typed as the global cloudflareEnv.

Checklist

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).
  • Link an issue if there is one related to your pull request. If no issue is linked, one will be auto-generated and linked.

@akshitsinha
akshitsinha force-pushed the fix/cloudflare-worker-entrypoint-rpc branch from 622dc60 to 76d20e4 Compare July 16, 2026 07:26
@akshitsinha
akshitsinha force-pushed the fix/cloudflare-worker-entrypoint-rpc branch from 76d20e4 to feb3ccd Compare July 16, 2026 07:29
@akshitsinha
akshitsinha marked this pull request as ready for review July 16, 2026 08:42
@akshitsinha
akshitsinha requested a review from a team as a code owner July 16, 2026 08:42
@akshitsinha
akshitsinha requested review from JPeer264, isaacs and mydea and removed request for a team July 16, 2026 08:42

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR. It actually looks pretty good already - I just have couple of comments, nothing critical.

Comment thread CHANGELOG.md Outdated
Comment thread packages/cloudflare/src/wrapMethodWithSentry.ts
Comment thread packages/cloudflare/src/wrapMethodWithSentry.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 792cc85. Configure here.

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks a lot for your contribution - that is really a nice addition

@JPeer264
JPeer264 merged commit 5c6574e into getsentry:develop Jul 17, 2026
287 checks passed
nicohrubec pushed a commit that referenced this pull request Jul 17, 2026
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #22310

Co-authored-by: JPeer264 <10677263+JPeer264@users.noreply.github.com>
@akshitsinha
akshitsinha deleted the fix/cloudflare-worker-entrypoint-rpc branch July 17, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloudflare WorkerEntrypointConstructor ignores its Env generic

2 participants